$(function () {
 // 自定义验证
 let form = layui.form
 let layer = layui.layer
 form.verify({
  pass: [
   /^[\S]{6,15}$/,
   '密码必须6到15位，且不能出现空格'
  ],
  newPwd: function (value) {
   let oldpwd = $('form [name="oldPwd"]').val()
   if (value == oldpwd) {
    return '不能与原密码相同'
   }
  },
  rePwd: function (value) {
   let newpwd = $('form [name="newPwd"]').val()
   if (value !== newpwd) {
    return '两次输入的密码不相同'
   }
  }

 })


 // 提交新密码
 $('.changePwd_form').on('submit', function (e) {
  e.preventDefault()
  axios({
   method: 'POST',
   url: '/my/updatepwd',
   data: $(this).serialize(),
   headers: {
    Authorization: localStorage.getItem('token')
   }
  }).then(function (res) {
   if (res.data.status !== 0) {
    return layer.msg(res.data.message)
   }
   // 成功后  提示,内容清空
   layer.msg('修改成功')
   $('.changePwd_form')[0].reset()
  })
 })

})